# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=snapper
pkgver=0.10.7
pkgrel=0
pkgdesc="Manage filesystem snapshots and allow undo of system modifications"
url="http://snapper.io"
arch="all"
license="GPL-2.0-or-later"
depends="dbus"
makedepends="
	acl-dev
	autoconf
	automake
	boost-dev
	bsd-compat-headers
	btrfs-progs-dev
	dbus-dev
	docbook-xsl
	e2fsprogs-dev
	gettext-dev
	json-c-dev
	libtool
	libxml2-dev
	libxslt
	lvm2-dev
	ncurses-dev
	"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-lang
	$pkgname-bash-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/openSUSE/snapper/archive/v$pkgver.tar.gz
	miss-tinfo-link-to-ncurses.patch
	drift-file-path.patch
	skip-locale-tests.patch
	statvfs64.patch
	"

prepare() {
	default_prepare

	# rename cron scripts
	sed -i -e 's@suse.de-@@g' scripts/Makefile.am
	# copy cron scripts to /etc/periodic/* instead of /etc/cron.*
	sed -i -e 's/cron\./periodic\//g' scripts/Makefile.am
	# fix config location in cron scripts
	sed -i -e 's@/etc/sysconfig/@/etc/snapper/@g' scripts/snapper-daily
	sed -i -e 's@/etc/sysconfig/@/etc/snapper/@g' scripts/snapper-hourly
	autoreconf -fvi
}

build() {
	export LDFLAGS="$LDFLAGS -lintl"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sbindir=/usr/sbin \
		--disable-silent-rules \
		--with-conf=/etc/snapper \
		--disable-pam \
		--disable-zypp \
		--disable-ext4 \
		--disable-systemd
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm644 data/sysconfig.snapper "$pkgdir"/etc/snapper/$pkgname
}

sha512sums="
bf098c941735b60554ff0711fa43b30ef3634e01178f5ee8ad44c65b757c3366bd5bf568cef3a787b2ddcc2fc63090056109250480e6bd360ebf27a8343373b8  snapper-0.10.7.tar.gz
3d264f7f9156342d5bad2ac78db9c8a30ea1ac25648245631a47d1495bb6610c6b39c28a5013741063df3c08f459388c0467caaedde5ad7cebb433eb432b7a70  miss-tinfo-link-to-ncurses.patch
c2470da8a5d62a37babdacd361051bae8fb3e1be157cb7eec1563a40825d41702f6f10bb619ffcab2ea8d7407405a543b0c47997c70a744c20cc3135c0532c1f  drift-file-path.patch
16f9991b0688c959977876e39e8ed9214627d3b3eacdf01a8aaef9540fc8add7d7c4f50abc4225183495acb161a4c6e5f6ee3790bf685fc845a6782647269a53  skip-locale-tests.patch
dc77db919fc4bd64929e784d09c4a6ed50530b6a88b3a26f4ea341f09e71dbd74e07d1e9fea37f85305d0f251a5c302e1dbb700084d04a16dc2e7687ecc83815  statvfs64.patch
"
